﻿#region
using System;
using System.IO;
using System.Linq;
#endregion

namespace DevTools.Immediate
{
    public class BinDeleter
    {
        private static readonly string[] _foldersToDelete;

        static BinDeleter()
        {
            _foldersToDelete = new string[]{"bin", "obj", "publish"};
        }

        public static void Delete(string path)
        {
            DirectoryInfo directory = new DirectoryInfo(path);

            var folders = directory.GetDirectories();

            foreach (var folder in folders)
            {
                if (_foldersToDelete.Contains(folder.Name))
                {
                    folder.Delete(true);
                    Console.WriteLine(folder);
                }
                else
                {
                    Delete(folder.FullName);
                }
            }
        }
    }
}